package cn.livingCloud.controller.core.validator;

import cn.livingCloud.dto.ReplySetFormDto;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 * Created by 唐旭 on 2016/6/2.
 */
@Component
public class ReplySetFormDtoValidator implements Validator {
    @Override
    public boolean supports(Class<?> aClass) {
        return ReplySetFormDto.class.equals(aClass);
    }

    @Override
    public void validate(Object target, Errors errors) {
        ReplySetFormDto formDto = (ReplySetFormDto) target;
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", null, "名称不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "content", null, "内容不能为空");
    }
}
